package edu.lsnu.equipment_management_system.mapper.insert;

import edu.lsnu.equipment_management_system.pojo.po.entity.UserTablePo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

/**
 * @author mzy
 * @Description 管理员增加一个用户
 * @date 2018/11/20
 */
public interface AdminAddUserMapper {
    /**
     * @Description 管理员添加一个用户
     * @author mzy
     * @time 2018-11-22
     * @see
     * @return   int
     * @params  [userTablePo]
     */
    @Insert("insert into YHB(ZGH, XM, MD5, YJSDM, YHLBDM) \n" +
            "values (#{userNo}, " +
            "#{userName}, " +
            "#{password}, " +
            "#{teacherOfficeNo}, " +
            "#{userCategoryNo})\n")
    int insertNewUser(UserTablePo userTablePo);

    /**
     * @Description 确保用户编号不存在
     * @author mzy
     * @time 2018-11-22
     * @see
     * @return   int
     * @params  [userNo]
     */
    @Select("select count(YHB.ZGH) from YHB where YHB.ZGH = #{userNo}")
    int existUser(String userNo);
}
